<?php

namespace app\index\service;

use app\index\model\UM as UM;
use ShidianUtil\Exception\DataNotExistException;
use app\index\dao\DocumentDao;
use app\common\model\Document;
use think\Collection;

/**
 * Class DocumentService
 * @package app\index\service
 */
class DocumentService
{
    // dao
    private DocumentDao $documentDao;

    public function __construct(DocumentDao $documentDao)
    {
        $this->documentDao = $documentDao;
    }

    /**
     * @param UM|null $user
     * @param $id
     * @param $type
     * @return Document|null
     */
    public function read(?UM $user, $id, $type): ?Document
    {

        if(!is_id($id) && is_null($type)){
            return null;
        }

        return $this->documentDao->findDocument($id, $type);
    }

}
